package com.thon.service.project.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thon.dao.project.ProjectUnsupportDao;
import com.thon.entity.project.ProjectUnsupport;
import com.thon.service.project.ProjectUnsupportService;

/**
 * @file ProjectUnsupportServiceImpl.java
 * @author Zemo
 * @email zemochen@lanbaoo.com
 * @date 2013年12月6日 下午8:05:57
 * @description TODO
 */
@Service
@Transactional
public class ProjectUnsupportServiceImpl implements ProjectUnsupportService {
	
	@Autowired
	private ProjectUnsupportDao projectUnsupportDao;

	@Override
	public boolean addUnsupport(ProjectUnsupport projectUnsupport) {
		
		if(projectUnsupportDao.countUnsupport(projectUnsupport.getProject().getId(), projectUnsupport.getUserId())==0){
			projectUnsupportDao.save(projectUnsupport);
			return true;
		}else{
			return false;
		}
		
	}

	@Override
	public Integer getUnSupportCount(Integer projectId) {
		return projectUnsupportDao.getUnSupportCount(projectId);
	}

}
